/*
 *  Copyright (c) 2009 Edwin Luis Choquehuanca Mamani
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */

#ifndef MONTECARLO_H_
#define MONTECARLO_H_

//#include "Algorithm.h"
#include <iostream>
#include "../../util/Data.h"

#include <math.h>

#define M1 259200
#define IA1 7141
#define IC1 54773
#define RM1 (1.0/M1)
#define M2 134456
#define IA2 8121
#define IC2 28411
#define RM2 (1.0/M2)
#define M3 243000
#define IA3 4561
#define IC3 51349

//class MonteCarlo: public Algorithm {
class MonteCarlo {
public:
	MonteCarlo(void);
	~MonteCarlo(void);
	template<class D> double algorithm(Data<D> *data){
		double pi = 0.0;
		int indice = data->getIndice();
		pi = piNumber(&indice,data->getBegin(), data->getEnd());
		return pi;
	}
private:
	int *num;
	//double rand1(int *idum);
	double piNumber(int *idum, int begin, int end);
	double rand1(int *idum, long *ix1, long *ix2, long *ix3, double *r, int *iff);
};

#endif


